import fs from 'node:fs'
if (!global.segment) {
    global.segment = (await import("oicq")).segment
}
const files = fs
    .readdirSync('./plugins/help-plugin/apps')
    .filter( file => file.endsWith('.js'))
let ret = []
files.forEach((file) => {
    ret.push(import(`./apps/${file}`))
})
ret = await Promise.allSettled(ret)
let apps = {}
for (let i in files) {
    let name = files[i].replace('.js', '')
    if (ret[i].status != 'fulfilled') {
        logger.error(`载入插件错误：${logger.red(name)}`)
        logger.error(ret[i].reason)
        continue
    }
    apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
export { apps }
logger.info(logger.blue('------------------'))
logger.info(logger.yellow('正在加载help插件~~'))
logger.info(logger.yellow('help插件加载完毕~~'))
logger.info(logger.blue('------------------'))